<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html >
<html>
<head>
<%@ include file="/WEB-INF/view/jQgrid.jsp"%>
</head>
<body style="background-color: white;" class="gray-bg">
	<div class="ibox-content">
		<form class="form-horizontal m-t " id="signupForm" method="post"
			enctype="multipart/form-data">
			<div class="form-group">
				<label class="col-sm-3 control-label">所属简历：</label>
				<div class="col-sm-8">
					<input type="text" name="resume.trueName" id="resumeName" class="form-control" placeholder="请选择简历"  onclick="chooseResume()" readonly="readonly"/>
				    <input type="hidden" name="resume.id" id="resumeId" class="form-control" />
				    <p class="help-block" style="color: red;">*必填项，请选择单个简历进行操作。</p>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">需求职位：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="functionalName" name="positionNames" onclick="openTree('functional');" placeholder="请选择需求职位"
										readonly="readonly" /> 
					<input type="hidden" name="position" id="functionalId" />
				</div>
			</div>
				<div class="form-group">
				<label class="col-sm-3 control-label">企业性质：</label>
				<div class="col-sm-8">
					<select class="form-control"  id="enterpriseNature" name="enterpriseNature" >
					<option value="">==请选择==</option>
					<c:forEach items="${fns:getDictList('company_nature')}" var="cnature">
					<option value="${cnature.value }">${cnature.valueName }</option>
					</c:forEach>
				</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">企业规模：</label>
				<div class="col-sm-8">
					<select class="form-control"  id="enterpriseScale" name="enterpriseScale" >
						<option value="">==请选择==</option>
						<c:forEach items="${fns:getDictList('company_scale')}" var="cscale">
						<option value="${cscale.value }">${cscale.valueName }</option>
						</c:forEach>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">企业发展阶段：</label>
				<div class="col-sm-8">
					<select class="form-control"  id="enterpriseDeveloping" name="enterpriseDeveloping" >
						<option value="">==请选择==</option>
						<c:forEach items="${fns:getDictList('company_deve')}" var="cdeve">
						<option value="${cdeve.value }">${cdeve.valueName }</option>
						</c:forEach>
					</select>
				</div>
			</div>
				<div class="form-group">
				<label class="col-sm-3 control-label">工作区域：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="area1Name" name="workAreaNames" onclick="openTree('area',1);" placeholder="请选择工作区域"
										readonly="readonly" /> 
					<input type="hidden" name="workArea" id="area1Id" />
				</div>
			</div>
				<div class="form-group">
				<label class="col-sm-3 control-label">是否出差和外派：</label>
				<div class="col-sm-8">
				   <input type="text" class="form-control" id="travel" name="travel" >
				</div>
			</div>
				<div class="form-group">
				<label class="col-sm-3 control-label">税前薪酬：</label>
				<div class="col-sm-8 form-inline">
					<input type="text" class="form-control" id="taxSalary" name="taxSalary" onblur="isIntDec('taxSalary',this.value);"/>（万人民币）
				</div>
			</div>
				<div class="form-group">
				<label class="col-sm-3 control-label">不考虑企业：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="lrrespective" name="lrrespective" />
				</div>
			</div>
				<div class="form-group">
				<label class="col-sm-3 control-label">期望的老板和团队：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="bossesTeams" name="bossesTeams" />
				</div>
			</div>
				<div class="form-group">
				<label class="col-sm-3 control-label">其他需求：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="other" name="other" />
				</div>
			</div>
				<div class="form-group">
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="remark" name="remark" />
				</div>
			</div>
			<div class="form-group" style="text-align: center;">
				<div class="col-sm-12">
					<button class="btn btn-primary" type="button" id="sub" >提交</button>
				</div>
			</div>
		</form>
	</div>


	<script>
    $(function () {
        $("#sub").click(function () {
        	//批量验证表单非空
			//调用方式
        	var arr=new Array(
        	  new Array('ResumeName','简历未选择!'),
        	  new Array('position','职位未填写!'),
        	  new Array('enterpriseNature','企业性质未填写!'),
        	  new Array('enterpriseScale','企业规模未填写!'),
        	  new Array('enterpriseDeveloping','企业发展阶段未填写!'),
        	  new Array('workArea','工作区域未填写!'),
        	  new Array('travel','是否出差和外派未填写!'),
        	  new Array('taxSalary','税前薪酬（万人民币）未填写!'),
        	  new Array('lrrespective','不考虑企业未填写!'),
        	  new Array('bossesTeams','期望的老板和团队未填写!'),
        	  new Array('other','其他需求未填写!')
        	);
        	  for(var i=0;i<arr.length;i++){
	        	  if($("#"+arr[i][0]).val()==''){
	        		  $("#"+arr[i][0]).tips({
	  					side:3,
	  		            msg:arr[i][1],
	  		            bg:'#AE81FF',
	  		            time:1
	  		        });
	        		  $("#"+arr[i][0]).focus();
	  				return;
	  			}
        	  }
            $("#signupForm").ajaxSubmit({
                url: '<%=contextPath%>/demandPersonal/add',
					type : 'post',
					dataType : "json",
					success : function(data) {
						if (data.code == 200) {
							swal({
								title : data.message,
								type : "success",
								showCancelButton : false,
								confirmButtonText : "确定",
								animation : "slide-from-bottom",
								closeOnConfirm : true
							}, function() {
								top.Dialog.close();
							});
						} else {
							swal("错误", data.message, "error");
						}
					}
				});

			});
		});
    //分配资源
	function openTree(obj,num){
	     var ids = $("#"+obj+"Id").val();
	   	 var diag = new top.Dialog();
		 diag.Drag=true;
		 diag.Title ="请选择";
		 diag.URL = '<%=contextPath %>/'+obj+'/openZtree?ids='+ids;
		 diag.Width = 250;
		 diag.Height = 400;
		 diag.CancelEvent = function(){ //关闭事件
			 var tempid = diag.innerFrame.contentWindow.document.getElementById('tempids').value;
			 var tempname = diag.innerFrame.contentWindow.document.getElementById('tempnames').value;
			if(tempid.length!==0){
				if(typeof(num)=="undefined"){ 
					$("#"+obj+"Id").val(tempid);
					$("#"+obj+"Name").val(tempname);
				}else{
					$("#"+obj+num+"Id").val(tempid);
					$("#"+obj+num+"Name").val(tempname);
				}
			}
			diag.close();
		 };
		 diag.show();
	}
	function chooseResume(){
		 var true_name = $("#resumeName").val();
	   	 var diag = new top.Dialog();
		 diag.Drag=true;
		 diag.Title ="请选择简历";
		 diag.URL = '<%=contextPath %>/resume/chooseResume?trueName='+true_name;
		 diag.Width = 750;
		 diag.Height = 700;
		 diag.CancelEvent = function(){ //关闭事件
			 var tempid = diag.innerFrame.contentWindow.document.getElementById('tempids').value;
			 var tempname = diag.innerFrame.contentWindow.document.getElementById('tempnames').value;
			if(tempid.length!==0){
					$("#resumeId").val(tempid);
					$("#resumeName").val(tempname);
			} 
			diag.close();
		 };
		 diag.show();
	}
	</script>
</body>
</html>